/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package vnc;

import gov.nist.core.Host;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import javax.microedition.io.Connector;
import javax.microedition.io.file.FileConnection;

/**
 *
 * @author javaking
 */
public class ReadSavedData {
    private String photos = "fileconn.dir.photos";
        private  String path;
     StringBuffer sb = new StringBuffer();
    public ReadSavedData(){

    try {
            path = System.getProperty(photos);
            String url = path + "Data.txt";
            FileConnection fconn = (FileConnection)Connector.open(url, Connector.READ_WRITE);
            if (!fconn.exists()) {
                fconn.create();
            }
            InputStream ips = fconn.openInputStream();
            int chars, i = 0;
      while ((chars = ips.read()) != -1){
        sb.append((char) chars);
      }

            ips.close();
            fconn.close();
        }
        catch (IOException ioe) {
            System.out.println("IOException: "+ioe.getMessage());
        }
        catch (SecurityException se) {
            System.out.println("Security exception:" + se.getMessage());
        }

    }
    public String getData(){
        return sb.toString();
    }

}
